Overview

This analysis explores oil spill incidents in California. Oil spill incident data are converted to spatial features and mapped over California’s county borders in an interactive Tmap. The data are also presented in a choropleth map to observe oil spill frequency by county.

Oil Spill Data Citation: Lampinen, Mark (2009). Oil Spill Incident Tracking [ds394]. California Department of Fish and Game, Office of Spill Prevention and Response. https://map.dfg.ca.gov/metadata/ds0394.html?5.108.39

California County Boundaries are sourced from the California Open Data Portal at: https://data.ca.gov/dataset/ca-geographic-boundaries/resource/b0007416-a325-4777-9295-368ea6b710e6

knitr::opts_chunk$set(echo = TRUE, message = FALSE, warning = FALSE)

library(tidyverse)
library(janitor)
library(here)
library(sf)
library(tmap)
library(tmaptools)
library(terra)

Wrangling oil spill and county data

## reading in oil spill data
oil <- read_csv(here("data/Oil_Spill_Incident_Tracking_[ds394].csv")) %>% 
  clean_names() 
  
## reading in county shapefile data and keeping only county name and geometry
counties <- read_sf(here("data/CA_Counties_TIGER2016.shp")) %>% 
  clean_names() %>% 
  select(name)

## converting oil spill data to sf
oil_sf <- st_as_sf(oil, coords = c("x", "y"),
                   crs = st_crs(counties)) # setting oil crs to match counties data

## checking to make sure crs matches
# st_crs(counties)
# st_crs(oil_sf)

Interactive map of California oil spill locations

## setting tmap mode and map style:
tmap_mode("view")
tmap_style("natural")

## mapping oil spill occurrences by CA county
tm_shape(counties) +
  tm_polygons(alpha = 0) +
tm_shape(oil_sf) +
  tm_dots(col = "salmon") 

Figure 1: Here we can observe the locations of oil spill incidents in the state of California. Red dots indicate locations of California oil spill occurances.

Choropleth map of inland oil spill locations in California

## including only inland oil spills
oil_inland <- oil_sf %>% 
  filter(inlandmari == "Inland")

## joining oil spill data to counties data
oil_inland_county <- counties %>% 
  st_join(oil_inland) %>% 
  ## getting counts of spills by county
  group_by(name) %>% 
  summarize(spills = n())

## creating choropleth map of spill counts by county
ggplot(data = oil_inland_county) +
  geom_sf(aes(fill = spills)) +
  theme_void() +
  scale_fill_gradientn(colors = c("mistyrose", "brown3", "purple4"))

Figure 2: This figure displays inland oil spill frequency by California county. Darker purple indicates a higher number of oil spills, while lighter colors indicate a lower number of spills.